package tools;

import java.util.Arrays;

public class Toolbox {
	
	public static long getMedium(long[] data) {
		Arrays.sort(data);
		
//		System.out.println(Arrays.toString(data));

		int midIndex = data.length / 2;
		
		int floating = data.length / 20;
		
		long[] mid = Arrays.copyOfRange(data, midIndex - floating, midIndex + floating + 1);
//		System.out.println(Arrays.toString(mid));
		long sum = 0;
		for (long d : mid) {
			sum += d;
		}
		
		return sum / mid.length;
	}
	
	
	public static void main(String[] args) {
		long[] a = {1, 2, 6, 3, 334, 31, 12, 54, 23, 3, 1, 2, 6, 3, 334, 31, 12, 54, 23, 3, 1, 2, 6, 3, 334, 31, 12, 54, 23, 3};
		getMedium(a);
	}

}
